package com.os.opencv.java.chapter4;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class Multiply {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        //填充矩阵1的数据并在控制台输出
        Mat mat1 = new Mat(9, 9, CvType.CV_8UC1);
        byte[] b1 = new byte[]{
                1, 2, 3, 4, 5, 6, 7, 8, 9,
                1, 2, 3, 4, 5, 6, 7, 8, 9,
                1, 2, 3, 4, 5, 6, 7, 8, 9,
                1, 2, 3, 4, 5, 6, 7, 8, 9,
                1, 2, 3, 4, 5, 6, 7, 8, 9,
                1, 2, 3, 4, 5, 6, 7, 8, 9,
                1, 2, 3, 4, 5, 6, 7, 8, 9,
                1, 2, 3, 4, 5, 6, 7, 8, 9,
                1, 2, 3, 4, 5, 6, 7, 8, 9
        };
        mat1.put(0, 0, b1);
        System.out.println(mat1.dump());

        //填充矩阵2的数据并在控制台输出
        Mat mat2 = new Mat(9, 9, CvType.CV_8UC1);
        byte[] b2 = new byte[]{
          1,1,1,1,1,1,1,1,1,
          2,2,2,2,2,2,2,2,2,
          3,3,3,3,3,3,3,3,3,
          4,4,4,4,4,4,4,4,4,
          5,5,5,5,5,5,5,5,5,
          6,6,6,6,6,6,6,6,6,
          7,7,7,7,7,7,7,7,7,
          8,8,8,8,8,8,8,8,8,
          9,9,9,9,9,9,9,9,9
        };
        mat2.put(0, 0, b2);
        System.out.println(mat2.dump());

        //将矩阵1和矩阵2点乘并在控制台输出
        Core.multiply(mat1, mat2, mat1);
        System.out.println(mat1.dump());
    }
}
